|
1
|
|
|
/** |
|
2
|
|
|
* PAYONE Magento 2 Connector is free software: you can redistribute it and/or modify |
|
3
|
|
|
* it under the terms of the GNU Lesser General Public License as published by |
|
4
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
|
5
|
|
|
* (at your option) any later version. |
|
6
|
|
|
* |
|
7
|
|
|
* PAYONE Magento 2 Connector is distributed in the hope that it will be useful, |
|
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10
|
|
|
* GNU Lesser General Public License for more details. |
|
11
|
|
|
* |
|
12
|
|
|
* You should have received a copy of the GNU Lesser General Public License |
|
13
|
|
|
* along with PAYONE Magento 2 Connector. If not, see <http://www.gnu.org/licenses/>. |
|
14
|
|
|
* |
|
15
|
|
|
* PHP version 5 |
|
16
|
|
|
* |
|
17
|
|
|
* @category Payone |
|
18
|
|
|
* @package Payone_Magento2_Plugin |
|
19
|
|
|
* @author FATCHIP GmbH <[email protected]> |
|
20
|
|
|
* @copyright 2003 - 2016 Payone GmbH |
|
21
|
|
|
* @license <http://www.gnu.org/licenses/> GNU Lesser General Public License |
|
22
|
|
|
* @link http://www.payone.de |
|
23
|
|
|
*/ |
|
24
|
|
|
/*jshint browser:true jquery:true*/ |
|
25
|
|
|
/*global alert*/ |
|
26
|
|
|
define([ |
|
27
|
|
|
'jquery', |
|
28
|
|
|
'Magento_Checkout/js/model/url-builder', |
|
29
|
|
|
'mage/storage', |
|
30
|
|
|
'Magento_Checkout/js/model/full-screen-loader', |
|
31
|
|
|
'Magento_Checkout/js/model/quote', |
|
32
|
|
|
'Magento_Customer/js/model/customer' |
|
33
|
|
|
], function ($, urlBuilder, storage, fullScreenLoader, quote, customer) { |
|
34
|
|
|
'use strict'; |
|
35
|
|
|
|
|
36
|
|
|
/** Override default place order action and add agreement_ids to request */ |
|
37
|
|
|
return function (addressData, isBillingAddress, baseView, type) { |
|
38
|
|
|
var serviceUrl; |
|
39
|
|
|
|
|
40
|
|
|
if (!customer.isLoggedIn()) { |
|
41
|
|
|
serviceUrl = urlBuilder.createUrl('/guest-carts/:quoteId/payone-addresscheck', { |
|
42
|
|
|
quoteId: quote.getQuoteId() |
|
43
|
|
|
}); |
|
44
|
|
|
} else { |
|
45
|
|
|
serviceUrl = urlBuilder.createUrl('/carts/mine/payone-addresscheck', {}); |
|
46
|
|
|
} |
|
47
|
|
|
var request = { |
|
48
|
|
|
addressData: addressData, |
|
49
|
|
|
isBillingAddress: isBillingAddress, |
|
50
|
|
|
isVirtual: quote.isVirtual(), |
|
51
|
|
|
dTotal: window.checkoutConfig.quoteData.subtotal |
|
52
|
|
|
}; |
|
53
|
|
|
|
|
54
|
|
|
fullScreenLoader.startLoader(); |
|
55
|
|
|
|
|
56
|
|
|
return storage.post( |
|
57
|
|
|
serviceUrl, |
|
58
|
|
|
JSON.stringify(request) |
|
59
|
|
|
).done( |
|
60
|
|
|
function (response) { |
|
61
|
|
|
if (response.success == true) { |
|
62
|
|
|
if (response.corrected_address != null) { |
|
63
|
|
|
if (!window.checkoutConfig.payment.payone.addresscheckConfirmCorrection || confirm(response.confirm_message)) { |
|
64
|
|
|
baseView.payoneUpdateAddress(response.corrected_address); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
baseView.payoneContinue(type); |
|
68
|
|
|
} else { |
|
69
|
|
|
alert(response.errormessage); |
|
70
|
|
|
} |
|
71
|
|
|
fullScreenLoader.stopLoader(); |
|
72
|
|
|
} |
|
73
|
|
|
).fail( |
|
74
|
|
|
function (response) { |
|
|
|
|
|
|
75
|
|
|
//errorProcessor.process(response, messageContainer); |
|
76
|
|
|
alert('An error occured.'); |
|
77
|
|
|
fullScreenLoader.stopLoader(); |
|
78
|
|
|
} |
|
79
|
|
|
); |
|
80
|
|
|
}; |
|
81
|
|
|
}); |
|
82
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.